import { defHttp } from '@/utils/http/axios';
import { bookListParams, bookDetailParams, bookSaveParams } from './model/bookModel';
import { BasicListResult, BasicDataResult } from '../model/baseModel';

import { ErrorMessageMode } from '#/axios';

enum Api {
  //Login = '/login',
  list = '/hl/sys/book/list',
  allList = '/hl/sys/book/allList',
  save = '/hl/sys/book/save',
  delete = '/hl/sys/book/delete',
  detail = '/hl/sys/book/detail',
  up = '/hl/sys/book/up',
  down = '/hl/sys/book/down',
}

/**
 * @description: user login api
 */
export function listApi(params: bookListParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicListResult>(
    {
      url: Api.list,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function allListApi(params: bookListParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicListResult>(
    {
      url: Api.allList,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function saveApi(params: bookSaveParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.save,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function detailApi(params: bookDetailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.detail,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function upApi(params: bookDetailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.up,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function downApi(params: bookDetailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.down,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function deleteApi(params: bookDetailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.delete,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
